# -------------------------------------------------------------------
#       -*- coding: utf-8 -*-
#   @Project    :   studentSystem
#   @File       :   taobaoReplay.py
#   @Author     :   WANGYU
#   @Time       :   2021-09-14 11:26:03
#   @Software   :   PyCharm
#   @Desc       :   
# -------------------------------------------------------------------


def find_answer(question):
    with open('replay.txt', 'r', encoding='utf-8') as file:
        while True:
            line = file.readline()
            if not line:  # 到文件末尾退出
                break
            # 字符串分割
            keyword = line.split('|')[0]
            replay = line.split('|')[1]
            if keyword in question:
                return replay
    return False


if __name__ == '__main__':
    question = input('hi,您好，有什么问题：')
    while True:
        if question == 'bye':
            break
        # 开始在文件中查找
        replay = find_answer(question)
        if not replay:
            question = input('不知道说的什么，可以问关于订单/物流/账户/支付的问题，退出输入bye')
        else:
            print(replay)
            question = input('可以继续问关于订单/物流/账户/支付的问题，退出输入bye')
    print('再见！')
